package cn.wolfcode.luowowo.website.web.controller;

import cn.wolfcode.luowowo.article.domain.Commodity;
import cn.wolfcode.luowowo.article.domain.UserCommodity;
import cn.wolfcode.luowowo.article.query.CommodityQuery;
import cn.wolfcode.luowowo.article.service.ICommodityService;
import cn.wolfcode.luowowo.article.service.IShopService;
import cn.wolfcode.luowowo.article.service.IUserCommodityService;
import cn.wolfcode.luowowo.article.service.IUserGoldService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import cn.wolfcode.luowowo.member.domain.UserInfo;
import cn.wolfcode.luowowo.website.annotation.UserParam;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("mall")
public class MallController {

    @Reference
    private IUserGoldService userGoldService;

    @Reference
    private ICommodityService commodityService;

    @Reference
    private IUserCommodityService userCommodityService;

    @Reference
    private IShopService shopService;

    @RequestMapping("ajax_virtual_goods/list")
    @ResponseBody
    public Object list(Model model, @UserParam UserInfo userInfo, Long flag , Long page, CommodityQuery query){

        Long uid = userInfo.getId();

        AjaxResult ajaxResult = new AjaxResult();

        ajaxResult.setError(false);

        ajaxResult.setData(123);

        List<UserCommodity> userCommodities = userCommodityService.selectByUserId(uid);

        ajaxResult.setTotal(userCommodities.size());

        return ajaxResult;
    }
}
